<!DOCTYPE html>
<html>
<head th:include="common/header_css::header('霸王餐小程序后台管理-商品信息','%mfile%datepicker%summernote')"></head>
<!--<head th:include="common/header_css::header('霸王餐小程序后台管理-拼团-发起拼团管理')"></head>-->
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div th:replace="common/toolbar::toolbar('开团记录管理')"></div>
        <div th:replace="common/search::search('no')"></div>
    </div>
    <!-- End Panel Basic -->
</div>

<!--添加PintuanOpen模态框-->
<div id="modal-add-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px;">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <h3 class="m-t-none m-b">开团记录添加</h3>
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content">
                                <form id="aform" method="post" class="form-horizontal" action="add"
                                      onsubmit="return checkAdd()">

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团id</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="ptid"
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">商品id *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="gid"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">手机号</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="phone"
                                                           type="number" phone maxlength="11"/>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">昵称 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="nickname"
                                                           required
                                                           type="text" maxlength="100"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">业务状态 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <select class="form-control" name="status">
                                                        <option value="1">未开启</option>
                                                        <option value="2">进行中</option>
                                                        <option value="3">拼团成功</option>
                                                        <option value="4">拼团失败</option>
                                                        <option value="5">活动结束</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">开团时间
                                                    *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="date" class="form-control selectData" readonly
                                                           id="starttime" name="starttime">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">结束时间
                                                    *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="date" class="form-control selectData" readonly
                                                           id="endtime" name="endtime">
                                                </div>
                                            </div>
                                        </div>


                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">开团设置总人数 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="ptotal"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">已参团人数</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="pnumber"
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">原始价格 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="price"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团价格 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="pinprice"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团优惠 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" name="cheapprice"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">是否组团 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" class="js-switch" name="isGroups" value="-1">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团成功时间
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="date" class="form-control selectData" readonly
                                                           id="successtime" name="successtime">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">开团描述海报</label>
                                                <div class="col-sm-10">
                                                    <div id="sninfo" class="summernote"></div>
                                                    <input type="hidden" id="info" name="info"/>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-2">
                                            <button class="btn btn-primary" type="submit">保存内容</button>
                                            <button data-toggle="modal" type="button" class="btn btn-white"
                                                    href="#modal-add-form">取消
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--修改PintuanOpen模态框-->
<div id="modal-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px;">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <h3 class="m-t-none m-b">开团记录修改</h3>
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content">
                                <form id="mform" method="post" class="form-horizontal" action="modify"
                                      onsubmit="return checkModify()">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团id</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="ptid" name="ptid"
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">商品id *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="gid" name="gid"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">手机号</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="phone" name="phone"
                                                           type="number" phone maxlength="11"/>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">昵称 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="nickname" name="nickname"
                                                           required
                                                           type="text" maxlength="100"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">业务状态 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <select class="form-control" name="status" id="status">
                                                        <option value="1">未开启</option>
                                                        <option value="2">进行中</option>
                                                        <option value="3">拼团成功</option>
                                                        <option value="4">拼团失败</option>
                                                        <option value="5">活动结束</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">开团时间 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control selectData" readonly
                                                           id="starttime2" name="starttime">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">结束时间 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control selectData" readonly
                                                           id="endtime2" name="endtime">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">开团设置总人数 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="ptotal" name="ptotal"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">已参团人数</label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="pnumber" name="pnumber"
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">原始价格 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="price" name="price"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团价格 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="pinprice" name="pinprice"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团优惠 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input class="form-control" id="cheapprice" name="cheapprice"
                                                           required
                                                           type="number"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">是否组团 *
                                                </label>
                                                <div class="col-sm-8">
                                                    <input type="checkbox" id="isGroups" name="isGroups" value="-1">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">拼团成功时间</label>
                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control selectData" readonly
                                                           id="successtime2" name="successtime">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">开团描述海报</label>
                                                <div class="col-sm-10">
                                                    <div id="sninfo2" class="summernote"></div>
                                                    <input type="hidden" id="info2" name="info"
                                                    />
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-2">
                                            <button class="btn btn-primary" type="submit">保存内容</button>
                                            <button data-toggle="modal" type="button" class="btn btn-white"
                                                    href="#modal-form">取消
                                            </button>
                                        </div>
                                    </div>
                                    <input id="id" name="id" type="hidden" value=""/>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:include="common/footer_js::footer"></div>
<script>

    //图片上传
    function sendFile(file, editor, $editable) {

        var filename = false;
        try {
            filename = file['name'];
        } catch (e) {
            filename = false;
        }
        if (!filename) {
            $(".note-alarm").remove();
        }
        //以上防止在图片在编辑器内拖拽引发第二次上传导致的提示错误
        data = new FormData();
        data.append("mfile", file);
        data.append("key", filename); //唯一性参数

        $.ajax({
            data: data,
            type: "POST",
            url: "/upload/file?type=sn_PintuanOpen",
            cache: false,
            contentType: false,
            processData: false,
            success: function (e) {
                console.log(e)
                if (e && e.code != 0) {
                    swal({title: "上传失败", text: "", type: "error"})
                    return;
                } else {
                    swal({title: "上传成功", text: "", type: "success"})
                }
                editor.insertImage($editable, e.data);
                setTimeout(function () {
                    $(".note-alarm").remove();
                }, 5000);
            },
            error: function () {
                swal({title: "上传失败", text: "", type: "error"})
                return;
            }
        });
    }

    $(document).ready(function () {
        $(".summernote").summernote({
            lang: "zh-CN",
            width: 535,
            height: 260,
            dialogsInBody: true,
            onImageUpload: function (files, editor, $editable) {
                sendFile(files[0], editor, $editable);
            }
        })
    });
</script>
<script src="/js/admin/pintuanopen.js"></script>
</body>
</html>
